package com.zf.shuashua.ui.home;

import android.content.Context;
import android.view.View;

import androidx.annotation.NonNull;

import com.lxj.xpopup.core.CenterPopupView;
import com.vise.xsnow.http.callback.ACallback;
import com.zf.shuashua.R;
import com.zf.shuashua.api.HttpData;
import com.zf.shuashua.bean.AddBlack;
import com.zf.shuashua.ui.mine.LogUtil;
import com.zf.shuashua.utils.ToastUtil;

public class BlackPopup extends CenterPopupView {

    private Context context;
    private String user_id;

    public BlackPopup(@NonNull Context context, String user_id) {
        super(context);
        this.context = context;
        this.user_id = user_id;
    }


    @Override
    protected int getImplLayoutId() {
        return R.layout.black_popup;
    }

    @Override
    protected void onCreate() {
        super.onCreate();
        findViewById(R.id.tvCancel).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();

            }
        });
        findViewById(R.id.tvConfirm).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                HttpData.getInstance().addBlank(user_id, new ACallback<AddBlack>() {
                    @Override
                    public void onSuccess(AddBlack data) {
                        if (data.getCode() == 200) {
                            ToastUtil.show(context, "拉黑成功");
                            dismiss();
                        }

                    }

                    @Override
                    public void onFail(int errCode, String errMsg) {
                        LogUtil.d("onFail" + "===" + errMsg);
                    }
                });

            }
        });

    }

}

